package com.jay.media.kit

import android.graphics.PorterDuff
import android.graphics.drawable.Drawable
import androidx.core.graphics.drawable.DrawableCompat

/**
 * @author xuzhou4
 * @date 2021/11/18
 */
object TintHelper {

    fun createTintDrawable(drawable: Drawable, color: Int): Drawable {
        val wrap = DrawableCompat.wrap(drawable)
        DrawableCompat.setTintMode(wrap, PorterDuff.Mode.SRC_IN)
        DrawableCompat.setTint(wrap, color)
        return wrap
    }
}